#!/usr/bin python3
# -*- coding:UTF-8 -*-
# Author: nigo
import pymysql

# 创建数据库连接
connect = pymysql.connect(host='127.0.0.1',
                          db='learn',
                          user='nigo',
                          passwd='1234',
                          charset='utf8')
# 创建游标对象cursor
# cursor = connect.cursor(cursor=pymysql.cursors.DictCursor)
cursor = connect.cursor()
# 要执行的sql语句
sql = "update ecommerce set country = '%s' where country = '%s'" % (
    '英国', 'United Kingdom')
try:
    # 执行SQL语句
    cursor.execute(sql)
    # 提交到数据库执行
    connect.commit()
except:
    # 发生错误时回滚
    connect.rollback()
# 关闭游标
cursor.close()
#  关闭连接
connect.close()
